import { AxiosRequestConfig } from 'axios'
import { getToken } from 'src/util/auth.js'

/*
  拦截器名称：全局设置请求的 token 内容
*/
const setToken = (config: AxiosRequestConfig) => {
  config.headers = config.headers || {}
  const token = getToken()
  if (token) {
    config.headers.Authorization = token
  }
  return config
}

export default setToken
